import * as classTransformer from "class-transformer";
import {ClassConstructor, ClassTransformOptions} from "class-transformer/types/interfaces";

/**
 * json => 类 转换器
 * @return void
 * @author allan
 * @example 2024/3/13
 */

export namespace classTransformerUtils {
    export const plainToClass = classTransformer.plainToClass;


    export function plainToClassExcludeExtraneousValues <T, V>(cls: ClassConstructor<T>, plain: V, options?: ClassTransformOptions) {
        return classTransformer.plainToInstance(cls, plain, {excludeExtraneousValues: true});
    }

    export const classToPlain = classTransformer.classToPlain;
}

